package com.example.mybatis.service.impl;

import com.example.mybatis.bean.Student;
import com.example.mybatis.bean.Teacher;
import com.example.mybatis.mapper.StudentMapper;
import com.example.mybatis.mapper.TeacherMapper;
import com.example.mybatis.service.TestService;
import com.example.mybatis.utils.ResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
@Slf4j
public class TestImpl implements TestService {
    @Resource
    StudentMapper studentMapper;
    @Resource
    TeacherMapper teacherMapper;
    @Override
    public ResultUtil select() {
      /*  System.out.println("select");
        log.info("普通信息", "info");
        log.warn("警告信息", "warn");
        log.error("错误信息", "error");
        log.debug("调试信息", "debug");
        Student student = new Student();
        student.setName("张三1");
        student.setAge(15);
        studentMapper.insert(student);
        log.info("插入成功，id:{}", student.getId());
        studentMapper.deleteById(1);*/


        Teacher teacher=new Teacher();
        teacher.setName("李四");
        teacher.setSex("女");
        teacherMapper.insertSelective(teacher);
        teacherMapper.selectList();
        log.info("插入成功，id:{}", teacher.getId());
        List<Teacher> teacherList1=teacherMapper.seleList("黎明","0");
        log.info("查询成功，结果：{}", teacherList1);
        teacher.setSex("男");
        int number = teacherMapper.updateSelectiveById(teacher);
        log.info("修改成功,id：{}", teacher.getId());

        List<Teacher> teacherList=teacherMapper.selectList();
        log.info("查询成功，结果：{}", teacherList);



   /*     List<Student> studentList=studentMapper.selectList("李","女");
        log.info("查询成功，结果：{}", studentList);*/

        return ResultUtil.ok();
    }

}
